import crypto from '../utils/crypto';
import * as express from 'express';
import db from '../utils/db';
import http from '../utils/http';

//获取类型声明//
import configs_win from '../configs_win';
const ACCOUNT_TYPE = configs_win.account_server();
type account_config = typeof ACCOUNT_TYPE;
//获取类型声明//



const app = express();




function send(res, ret) {
    let str = JSON.stringify(ret);
    res.send(str);
}


/**设置跨域访问 */
app.all('*', function (req, res, next) {
    res.header('Access-Control-Allow-Origin', '*');
    res.header('Access-Control-Allow-Headers', 'X-Requested-With');
    res.header('Access-Control-Allow-Methods', 'PUT,POST,GET,DELETE,OPTIONS');
    res.header('X-Powered-By', '3.2.1');
    res.header('Content-Type', 'application/json;charset=utf-8');
});






export default class Dapi {

    /**
     * 开启发牌服务器
     * @param config 
     */
    static start(config: account_config) {
        app.listen(config.DEALDER_API_PORT, config.DEALDER_API_IP);
        console.log('发牌服务器运行在：' + config.DEALDER_API_IP + ':' + config.DEALDER_API_PORT);
    }

}